package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.SelectExamRequest;
import com.ytjj.qmyx.admin.model.request.exam.SelectExamProposeRequest;
import com.ytjj.qmyx.admin.service.SelectExamService;
import com.ytjj.qmyx.mall.model.SelectExam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 *
 * @Version: 1.0
 *
 * 选品审核模块
 */
@RestController
@RequestMapping("/selectExam")
public class SelectExamController {

	@Resource
	private SelectExamService selectExamService;

	@GetMapping("/list")
	@OperLog(operModule = "选品审核模块", operDesc = "商品列表", operType = SysLogConstants.OPERATION_SELECT)
	public CommonResult selectList(SelectExamRequest request) {
		return CommonResult.success(selectExamService.selectList(request));
	}

	@GetMapping("/insert")
	@OperLog(operModule = "选品审核模块", operDesc = "新增", operType = SysLogConstants.OPERATION_ADD)
	public CommonResult insertSelect(SelectExam selectExam) {
		return CommonResult.success(selectExamService.insertSelect(selectExam));
	}

	@GetMapping("/startExam")
	@OperLog(operModule = "选品审核模块", operDesc = "初审核", operType = SysLogConstants.OPERATION_UPDATE)
	public CommonResult startExam(@RequestParam Integer id, @RequestParam Integer startStatus, @RequestParam String startOpinion) {
		return CommonResult.success(selectExamService.startExam(id, startStatus, startOpinion));
	}

	@GetMapping("/endExam")
	@OperLog(operModule = "选品审核模块", operDesc = "终审核", operType = SysLogConstants.OPERATION_UPDATE)
	public CommonResult endExam(@RequestParam Integer id, @RequestParam Integer endStatus, @RequestParam String endOpinion) {
		return CommonResult.success(selectExamService.endExam(id, endStatus, endOpinion));
	}

	@GetMapping("/update")
	@OperLog(operModule = "选品审核模块", operDesc = "编辑", operType = SysLogConstants.OPERATION_UPDATE)
	public CommonResult updateSelect(SelectExam selectExam) {
		return CommonResult.success(selectExamService.updateSelect(selectExam));
	}

	/**
	 * 终审  以及建议
	 */
	@PostMapping("/propose")
	@OperLog(operModule = "选品审核模块", operDesc = "终审、建议", operType = SysLogConstants.OPERATION_ADD)
	public CommonResult propose(@Validated @RequestBody SelectExamProposeRequest selectExamProposeRequest) {
		selectExamService.propose(selectExamProposeRequest);
		return CommonResult.success();
	}

	/**
	 * 获取审核建议
	 */
	@GetMapping("/getPropose")
	@OperLog(operModule = "选品审核模块", operDesc = "审核建议", operType = SysLogConstants.OPERATION_SELECT)
	public CommonResult getPropose(@RequestParam Integer selectExamId) {
		return CommonResult.success(selectExamService.getPropose(selectExamId));
	}

	@GetMapping("/updateExpressNo")
	@OperLog(operModule = "选品审核模块", operDesc = "录入快递单号", operType = SysLogConstants.OPERATION_ADD)
	public CommonResult updateExpressNo(@RequestParam Integer selectExamId, @RequestParam String sampleExpressNo) {
		selectExamService.updateExpressNo(selectExamId, sampleExpressNo);
		return CommonResult.success();
	}

	@GetMapping("/updateContentStatus")
	@OperLog(operModule = "选品审核模块", operDesc = "是否完成工作", operType = SysLogConstants.OPERATION_UPDATE)
	public CommonResult updateContentStatus(@RequestParam Integer selectExamId) {
		selectExamService.updateContentStatus(selectExamId);
		return CommonResult.success();
	}

}
